DEMO #1: In this demo, you'll use a variable to store a number, then use that variable in a command!

A variable is a name that stores a value. In this program, we are going to use variables to store numbers that are generated randomly! A variable creation statement uses an equal sign to connect the name to the stored value.

  • Hover over the parts of the variable creation statement on the stage to learn more about each part.
  • Try clicking the person, then click Run again to see what changes on stage!

To navigate the page using the TAB key, first press ESC to exit the code editor.

sprite = codesters.Sprite("person11", 0, -60) sprite.set_size(.8) #Pick a random number from 1 to 360 and store it in secret_number secret_number = random.randint(1,360) stage.wait(2) sprite.turn_right(secret_number)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)